package oop.ex3.nameserver.actions;

import java.net.InetSocketAddress;
import java.util.Set;

import oop.ex3.messages.MessageInterface;
import oop.ex3.nameserver.NSContext;
import oop.ex3.sockets.ClientSocket;

public class ClearFiles extends NsAction {
	
	public ClearFiles(NSContext context){
		super(context);
	}

	@Override
	public boolean run(ClientSocket socket, MessageInterface msg) {
		InetSocketAddress fm = socket.getOtherPeer();
		Set<String> files = _context.removeFm(fm);
		for (String file : files){
			_context.deleteFromFileList(file, fm);
		}
		return sendDone(socket);
	}

}
